package br.com.dallasmotopecas.eptus.fabricante.controller;

import java.sql.Connection;
import java.util.List;

import javax.faces.context.ExternalContext;

import br.com.dallasmotopecas.comum.fabricante.vo.FabricanteVo;
import br.com.dallasmotopecas.eptus.fabricante.model.FabricanteEptusModel;
import br.com.dallasmotopecas.util.controller.AbstractController;
import br.com.dallasmotopecas.util.exception.ClasseNaoEncontradaException;
import br.com.dallasmotopecas.util.exception.ConexaoException;
import br.com.dallasmotopecas.util.exception.ListarObjetoException;

public class FabricanteEptusController extends AbstractController
{
	public FabricanteEptusController(Connection connection) throws ConexaoException
	{
		super(connection);
	}

	public FabricanteEptusController(ExternalContext externalContext) throws ClasseNaoEncontradaException, ConexaoException
	{
		super(externalContext);
	}
	
	public void carregarListaFabricante(List<FabricanteVo> listaFabricante) throws ListarObjetoException
	{
		FabricanteEptusModel fabricanteEptusModel = null;
		try
		{
			if (listaFabricante != null)
			{
				listaFabricante.clear();
				fabricanteEptusModel = new FabricanteEptusModel(getConnection());
				listaFabricante.addAll(fabricanteEptusModel.getListaFabricante());
			}
		}
		catch(ListarObjetoException e)
		{
			throw e;
		}
		finally
		{
			fabricanteEptusModel = null;
		}
	}
}
